
package bsc.war.ajax;

import bsc.ejb.entity.DimensionMember;
import bsc.war.delegate.DelegateBSC;
import bsc.war.factory.Factory;
import java.util.List;

/**
 *
 * @author castrosalazr
 */
public class AjaxDesignerDrillTag
{
    public static String drillDimensionMember(DimensionMember member)
    {
        DelegateBSC delegate = (DelegateBSC) Factory.getBean("DelegateBSC");
        List<DimensionMember> children = delegate.findDimensionMember(member);
        StringBuffer buffer = new StringBuffer();

        buffer.append("<li>");
        buffer.append("<input type=\"hidden\" name=\"existingDimensionMember\" value=\""+member.getIdDimensionMember()+"\" />");
        buffer.append("<label for=\"existingDimensionMember-"+member.getIdDimensionMember()+"\">Nombre de miembro:</label>");
        buffer.append("<input id=\"existingDimensionMember-"+member.getIdDimensionMember()+"\" name=\"existingDimensionMember-"+member.getIdDimensionMember()+"\" class=\"designerWizardInput\" style=\"width:200px\" value=\""+member.getName()+"\" />");
        buffer.append("<ul>");

        if(children != null && children.size()>0)
            for(DimensionMember child : children)
                buffer.append(drillDimensionMember(child));

        buffer.append("<li class=\"addDimensionMemberLink\"><a href=\"#\">Agregar miembro</a></li>");
        buffer.append("</ul>");
        buffer.append("</li>");
        return buffer.toString();
    }
}
